package com.singfan.script;

import com.singfan.core.dao.database.IOrderDao;
import com.singfan.core.dao.database.model.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * Author: hansonghe
 * Date: 2015-10-20 13:59
 * Desc:
 */
@Component
public class MokeDataScript extends ScriptRunner {
    @Autowired
    private IOrderDao orderDao;
    @Override
    public void run(List<String> args) {
        List<Orders> ordersList = orderDao.selectOneMonthOrdersList(201509, -1);
        Random r = new Random();
        for (Orders order : ordersList){
            order.setArrivalTime(new Date(2015 - 1900, 8, r.nextInt(30) + 1));
            orderDao.update(order);
        }
    }
}
